package com.example.mapper;

import com.example.domain.User;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author zhangming
 * @Date 2021/10/8 14:02
 * @Version 1.0
 * @Desc:
 */
@Repository
public class UserMapper {

    private static final Map<Integer, User> USER_MAP = new HashMap<>(2);

    static {
        USER_MAP.put(1, new User(1, "张三", 12, "测试地址"));
        USER_MAP.put(2, new User(2, "李四", 16, "测试地址"));
    }

    /**
     * 根据Id获取
     * @param id
     * @return
     */
    public User getById(Integer id) {
        return USER_MAP.get(id);
    }

}
